# -*- coding: utf-8 -*-
# @Time        :2025/4/21 16:49
# @Author      :文刀水寿
# @File        : models.py
"""
 @Description :
"""
# 选课
from tortoise.models import Model
from tortoise import fields


class Student(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=32, description="姓名")
    pwd = fields.CharField(max_length=32, description="密码")
    sno = fields.IntField(description="学号")

    # 一对多的联系
    clas = fields.ForeignKeyField("models.Clas", related_name="students")  # 生成cla_id

    # 多对多的联系
    course = fields.ManyToManyField("models.Course", related_name="学生选课表")


class Clas(Model):
    name = fields.CharField(max_length=32, description="班级名称")


class Course(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=32, description="课程名称")
    teacher_name = fields.ForeignKeyField("models.Teacher")


class Teacher(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=32, description="老师姓名")
    pwd = fields.CharField(max_length=32, description="密码")
    tnumber = fields.IntField(description="学号")
